package drds.datasource.connection_pool.impl.thread;

import drds.datasource.connection_pool.impl.DataSource;

import java.sql.SQLException;

public class DestroyConnectionTask implements Runnable {

    private final DataSource dataSource;

    public DestroyConnectionTask(DataSource dataSource) {
        this.dataSource = dataSource;

    }

    @Override
    public void run() {
        try {
            this.dataSource.shrink(true, this.dataSource.keepAlive);
            if (this.dataSource.isSupportRemoveAbandoned()) {
                this.dataSource.removeAbandoned();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }

}